<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4102：[Usaco2015 Open]Bessie</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Open]Bessie</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Open]Bessie</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Usaco2015 Open]Bessie                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>For Bessie the cow&rsquo;s birthday, Farmer John has given her free reign over one of his best fields to eat grass.</div>
<div>The field is covered in N patches of grass (1&le;N&le;1000), conveniently numbered 1&hellip;N, that each have a distinct</div>
<div>quality value. If Bessie eats grass of quality Q, she gains Q units of energy. Each patch is connected to up to 10</div>
<div>neighboring patches via bi-directional paths, and it takes Bessie E units of energy to move between adjacent</div>
<div>patches (1&le;E&le;1,000,000). Bessie can choose to start grazing in any patch she wishes, and she wants to stop</div>
<div>grazing once she has accumulated a maximum amount of energy.</div>
<div>Unfortunately, Bessie is a picky bovine, and once she eats grass of a certain quality, she&rsquo;ll never eat grass at or</div>
<div>below that quality level again! She is still happy to walk through patches without eating their grass; in fact, she</div>
<div>might find it beneficial to walk through a patch of high-quality grass without eating it, only to return later for a tasty snack.</div>
<div>Please help determine the maximum amount of energy Bessie can accumulate.</div>
<div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">为了庆祝贝茜的生日,FJ给她吃草的自由. N块草地,标号1到N(1&lt;=N&lt;=1000),草地有营养价值.当贝茜走到这个草地,可以获得等于这块草地的营养价值的能量. 每块草地最多有10条双向边,每走一条边,贝茜花费E的能量. 贝茜拿可以从任何地方出发,当她不能获得更多的能量的时候她就会停止. 然而因为贝茜挑食,她每次不会吃低于或等于上次的营养价值的草地,所以她获得的能量是严格上升的,当然她可以选择只是经过一块草地而不吃草.</div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">算出贝茜能够获得的最大能量.</div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;"></div>
</div>
<div></div>
<div></div>
<p></p></p><hr/><h3>输入格式</h3><p><div>The first line of input contains N and E. Each of the remaining N lines describe a patch of grass.</div>
<div>They contain two integers Q and D giving the quality of the patch (in the range 1&hellip;1,000,000) and</div>
<div>its number of neighbors. The remaining D numbers on the line specify the neighbors.</div>
<div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">第一排两个数 N和E</div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">剩下N排,每排包含Q,D两个数字,Q代表这个草地的营养价值,D代表这个点的边数,剩下D个数表示于这块草地相邻的草地.</div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;"></div>
</div>
<div></div>
<p></p></p><hr/><h3>输出格式</h3><p><div>Please output the maximum amount of energy Bessie can accumulate.</div>
<div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">一个整数</div>
<div style="font-family: Helvetica, 'Microsoft Yahei', verdana; font-size: 14px; line-height: 15.333333015441895px;">最大权值</div>
</div>
<div></div>
<p></p></p><hr/><h3>样例输入</h3><pre>5 2
4 1 2
1 3 1 3 4
6 2 2 5
5 2 2 5
2 2 3 4</pre><hr/><h3>样例输出</h3><pre>7
Bessie starts at patch 4 gaining 5 units of energy from the grass there. She then takes the path to patch 5 losing 2 units of energy during her travel. She refuses to eat the lower quality grass at patch 5 and travels to patch 3 again losing 2 units of energy. Finally she eats the grass at patch 3 gaining 6 units of energy for a total of 7 energy.
Note tha the sample case above is different from test case 1 when you submit.
</pre><hr/><h3>提示</h3><p><p>&nbsp;求译文!请发至lydsy2012@163.com</p></p><hr/><h3>题目来源</h3><p>Silver 鸣谢yeguanghao提供译文</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4102" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4102" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>